/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SortingThreads;

import Sorting.Main;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.j3d.BranchGroup;
import javax.swing.JOptionPane;

/**
 *
 * @author rafael
 */
public class CountingThread extends Thread {

    public CountingThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        execute();
    }

    private void execute() {
        try {


            Main.textPane.setText(Main.textoCounting);
            BranchGroup bgroup = Main.addCountingBranchGroup();
            Main.su.addBranchGraph(bgroup);

            try {
                Thread.sleep(200);
            } catch (InterruptedException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }

            Main.countingSort(Main.vetorNumeros, Main.getMinimumValue(Main.vetorNumeros), Main.getMaximumValue(Main.vetorNumeros));

            JOptionPane.showMessageDialog(null, "Ordenação concluída");
            Main.sc.show(Main.frame);


            Main.removeElements(Main.vetorCounting);
            Main.removeElements(Main.vetorNumeros);
            Main.removeElements(Main.changeableVector);


        } finally {
            Main.isRunning = false;
            Main.clearTexts();
        }
    }
}
